package com.justreading.nio.zerocopy;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.SocketChannel;

/**
 * @author LYJ
 * @Description
 * @date 2021 年 10 月 07 日 18:26
 */
public class NewIOClient {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress("127.0.0.1",6668));
        File file = new File("1.txt");
        FileChannel fileChannel = new FileInputStream("1.txt").getChannel();
        fileChannel.transferTo(0,file.length(),socketChannel);
        System.out.println("拷贝完成");
        fileChannel.close();
    }
}
